#ifndef  __HEAD_H__
#define  __HEAD_H__

#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<malloc.h>
#include<string.h>
#include<stdbool.h>

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#define COMMODITYCODESIZE 14
#define COMMODITYNAMESIZE 14
#define STOREHOURSE 100
#define PRODUCTDATASIZE  14

//商品属性结构体
typedef struct good_attribute{
	char commoditycode[COMMODITYCODESIZE];  //商品编码
	char commodityname[COMMODITYNAMESIZE ]; //商品名称
	float spec;		
	char kg[4];		//商品规格 kg/L
	float price;	//单价
	char sell_by_data[PRODUCTDATASIZE];  //生产日期
	int validitydata; //保质期
	char valibuf[4];
	int quantity;     //库存量
}g_attribute;

//仓库中商品存储的结构体
typedef struct storehourse{							//相当于与商品表单
	struct good_attribute attr[STOREHOURSE];//每个元素存放一个商品
	int index;
}store,*pstore;

//已购商品链表
typedef struct good_struct{
		struct good_attribute attr;
		struct good_struct* prior, * next; //定义前驱后继指针
}DNode,*DLinkList;

//登记购买商品结构体
struct good_enterup{
	struct good_attribute attr;
	struct good_struct link;
	
};



struct commoditycode{
	char commoditycode[COMMODITYCODESIZE];  //商品编码
	struct commoditycode *next;
};

//取消购买结构体
struct good_cancel{
	float cancelprice;
	struct commoditycode code;
};

typedef struct choose_goodlink{
	char commoditycode[COMMODITYCODESIZE];
	struct choose_goodlink* next;
}Node,*LinkList;

//购买商品的任务结构体
typedef struct task_str{
	float totalprice;
	struct storehourse allgoodlist;
	struct good_enterup goodlogin;   //此结构体未真正用到
	struct good_struct* goodlist;
	struct good_cancel goodcode;	//此结构体未真正使用到
	struct choose_goodlink *choosegood;
}task,*ptask;

ptask InitOperatorFunc();
void FuncGroup(ptask regood);
void PrintStoreAllInfo(ptask regood);
void StoreCommodityInit(ptask commodity);
void AllGoodListInit(ptask* goodlist);
void DLinkListInit(ptask good);
bool GoodEnterUp(ptask good);
void PrintPurchaseGoodInfo(ptask good );
void GoodEnterUpInit(ptask good);
void GoodCancelInit(ptask good);
void FreeStoreSpace(ptask good);

void CreatSingleLinkInit(ptask good);
void CreatSingleLink(ptask good,char *recomdtycode);
void PrintSignalList(ptask good);

void GoodCancel(ptask good);
void CountPrine(ptask good);

void HelpDocument();
#endif